package com.com.ruanmeng.utils;

import android.content.Context;
import android.os.CountDownTimer;
import android.widget.TextView;

import com.example.lenovo.weiyi.R;


/**
 * 作者 孔卫瑞
 * 时间 2017/2/14 0014.
 * 公司 郑州软盟
 */

public class TimeCount extends CountDownTimer {
    TextView textView;
    Context context;

    public TimeCount(Context context, long millisInFuture, long countDownInterval, TextView bt) {
        super(millisInFuture, countDownInterval);// 参数依次为总时长,和计时的时间间隔
        this.textView = bt;
        this.context = context;
    }

    @Override
    public void onFinish() {// 计时完毕时触发
        textView.setText("获取验证码");
        textView.setClickable(true);
        textView.setTextColor(context.getResources().getColor(R.color.MainColor));
        textView.setBackgroundResource(R.drawable.ed_main);
    }

    @Override
    public void onTick(long millisUntilFinished) {// 计时过程显示
        textView.setClickable(false);
        textView.setTextColor(context.getResources().getColor(R.color.ThirdGrayColor));
        textView.setText(millisUntilFinished / 1000 + " 秒后重发");
        textView.setBackgroundResource(R.drawable.ed_gray);
    }
}
